package project;

import java.awt.Point;

abstract class Move implements MoveIF {

	protected Point coords;
	protected int player;
	
	Move(String move, int player) {
		coords = new Point(move.charAt(0) - 'a', move.charAt(1) - '1');
    	this.player = player;
	}
	
	public static Move newMove(String move, int player) {
		if (move.length() == 2) {
			return new PawnMove(move, player);
		} else {
			return new WallMove(move, player);
		}
	}
	
	public int getX() {
		return coords.x;
	}
	
	public int getY() {
		return coords.y;
	}
	
	public Point getCoords() {
		return coords;
	}
	
	public int getPlayer() {
		return player;
	}
	
	public String toString() {
		StringBuilder ret = new StringBuilder();
		ret.append((char)('a'+coords.x));
		ret.append((char)('1'+coords.y));
		if (this instanceof WallMove) {
			ret.append(((WallMove)this).isHorizontal? 'h': 'v');
		}
		return ret.toString();
	}
}